package handlers

import (
	"awesome-devops/applications/backend/modules/define"
	"awesome-devops/applications/models"
	"gitee.com/jjawesomejj/awesome-util/helper/commonhelper"
	awesomehttp "gitee.com/jjawesomejj/awesomehttp/system"
)

type ApiHandler struct {
	awesomehttp.HttpBaseHandler
}

func (context *ApiHandler) GetModuleName() string {
	return "/api/"
}

func (context *ApiHandler) ActionCurrentUser() string {
	exampleData := `{
	"success": true,
	"data": {
		"name": "{}",
		"avatar": "https://gw.alipayobjects.com/zos/antfincdn/XAosXuNZyF/BiazfanxmamNRoxxVxka.png",
		"userid": "00000001",
		"email": "antdesign@alipay.com",
		"signature": "海纳百川，有容乃大",
		"title": "交互专家",
		"group": "",
		"tags": [],
		"notifyCount": 12,
		"unreadCount": 11,
		"country": "China",
		"access": "",
		"geographic": {
			"province": {
				"label": "浙江省",
				"key": "330000"
			},
			"city": {
				"label": "杭州市",
				"key": "330100"
			}
		},
		"address": "",
		"phone": ""
	}
}`
	user := context.HttpContext.GetValue("login_user").(models.User)
	exampleData = commonhelper.Format(exampleData, user.Username)
	return exampleData
}

func (context *ApiHandler) ActionNotices() interface{} {
	return define.JsonResponse(*context.HttpContext, make([]interface{}, 0))
}
